package cn.stylefeng.guns.modular.yingbao.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.yingbao.entity.SysUserGroup;
import cn.stylefeng.guns.modular.yingbao.model.params.SysUserGroupParam;
import cn.stylefeng.guns.modular.yingbao.service.SysUserGroupService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 用户团队表控制器
 *
 * @author jj
 * @Date 2019-12-18 13:51:40
 */
@CrossOrigin
@Api(tags = "团队记录")
@Controller
@RequestMapping("/sysUserGroup")
public class SysUserGroupController extends BaseController {

    private String PREFIX = "/sysUserGroup";

    @Autowired
    private SysUserGroupService sysUserGroupService;

    /**
     * 跳转到主页面
     *
     * @author jj
     * @Date 2019-12-18
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/sysUserGroup.html";
    }

    /**
     * 新增页面
     *
     * @author jj
     * @Date 2019-12-18
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/sysUserGroup_add.html";
    }

    /**
     * 编辑页面
     *
     * @author jj
     * @Date 2019-12-18
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/sysUserGroup_edit.html";
    }

    /**
     * 新增接口
     *
     * @author jj
     * @Date 2019-12-18
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(SysUserGroupParam sysUserGroupParam) {
        this.sysUserGroupService.add(sysUserGroupParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author jj
     * @Date 2019-12-18
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(SysUserGroupParam sysUserGroupParam) {
        this.sysUserGroupService.update(sysUserGroupParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author jj
     * @Date 2019-12-18
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(SysUserGroupParam sysUserGroupParam) {
        this.sysUserGroupService.delete(sysUserGroupParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author jj
     * @Date 2019-12-18
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(SysUserGroupParam sysUserGroupParam) {
        SysUserGroup detail = this.sysUserGroupService.getById(sysUserGroupParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author jj
     * @Date 2019-12-18
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(SysUserGroupParam sysUserGroupParam) {
        return this.sysUserGroupService.findPageBySpec(sysUserGroupParam);
    }

    /**
     * 我的团队
     *
     * @author jj
     * @Date 2019-12-18
     */
    @ApiOperation("查看所有我的团队用户")
    @ResponseBody
    @RequestMapping(value = "/groupList",method = RequestMethod.POST)
    public ResponseData groupList(Long userid,int pageNum, int pageSize) {
        return this.sysUserGroupService.groupList(userid,pageNum,pageSize);
    }

    /**
     * 我的团队
     *
     * @author jj
     * @Date 2019-12-18
     */
    @ApiOperation("查看我的团队一级用户")
    @ResponseBody
    @RequestMapping(value = "/groupyjList",method = RequestMethod.POST)
    public ResponseData groupyjList(Long userid,int pageNum, int pageSize) {
        return this.sysUserGroupService.groupyjList(userid,pageNum,pageSize);
    }
   /**
     * 我的团队
     *
     * @author jj
     * @Date 2019-12-18
     */
    @ApiOperation("查看我的团队二级用户")
    @ResponseBody
    @RequestMapping(value = "/groupejList",method = RequestMethod.POST)
    public ResponseData groupejList(Long userid,int pageNum, int pageSize) {
        return this.sysUserGroupService.groupejList(userid,pageNum,pageSize);
    }
    /**
     * 我的团队结果
     *
     * @author jj
     * @Date 2019-12-18
     */
    @ResponseBody
    @RequestMapping(value = "/groupeSum",method = RequestMethod.POST)
    @ApiOperation("查看我的团队结果")
    public ResponseData groupeSum(Long userid) {
        return this.sysUserGroupService.groupeSum(userid);
    }
    /**
     * 根据ID搜索
     *
     * @author jj
     * @Date 2019-12-18
     */
    @ApiOperation("根据ID搜索" )
    @ResponseBody
    @RequestMapping(value = "/sreachID",method = RequestMethod.POST)
    public ResponseData sreachID(Long id,Long userid) {
        return this.sysUserGroupService.sreachID(id,userid);
    }
}


